/*
 * This file is part of quickReminder, a software for gamers
 *
 * Copyright (C) 2006-2008 Lucas Romero
 *
 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace ESLReminder.Modules.WarnModules
{
    public abstract class WarnTimerModule
    {
        Timer m_WarnTimer = null;
        private bool m_Warning = false;
        private int m_WarnInterval;

        public WarnTimerModule(int warninterval)
        {
            m_WarnInterval = warninterval;
            m_WarnTimer = new Timer(new TimerCallback(WarnDelegate), null, Timeout.Infinite, warninterval);
        }

        ~WarnTimerModule()
        {
            Stop();
        }
    
        public int WarnInterval
        {
            get
            {
                return m_WarnInterval;
            }
            set
            {
                m_WarnInterval = value;
            }
        }
    
        public abstract void Warn();
        public virtual void BeforeStart()
        {
            //nothing
        }
        public virtual void AfterStopped()
        {
            //nothing
        }
        private void WarnDelegate(object dummy)
        {
            Warn();
            System.Diagnostics.Trace.WriteLine("Warn!");
        }
        public void Start()
        {
            BeforeStart();
            m_WarnTimer.Change(0, m_WarnInterval);
        }
        public void Stop()
        {
            return;
            if (m_WarnTimer != null)
            {
                m_WarnTimer.Change(Timeout.Infinite, Timeout.Infinite);
                AfterStopped();
            }
        }
    }
}
